<template>
  <el-button type="danger" @click="delRow" :loading="loading">{{$t('common.revoke')}}</el-button>
</template>

<script>
import {deleteTransferWork} from "@/api/transferWork";

export default {
  name: "DeleteButton",
  props:{
    id:{
      type: Number,
      required: true,
    },
  },
  data(){
    return {
      loading: false,
    }
  },
  methods:{
    delRow(){
      this.$warning( '',{
        title: this.$t('transfer.撤销当前调货？'),
      })
        .then(()=>{
          this.loading = true
          deleteTransferWork(this.id)
            .then(res=>{
              this.loading = false
              if(res.error === 0){
                this.$successMessage(res.message)
                this.$emit('deleteWork')
              }else{
                this.$errorMessage(res.message)
              }
            })
        })
        .catch(()=>{

        })
    }
  }
}
</script>

<style scoped>

</style>
